<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="overflow-y:auto">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理后台</title>
<link rel="stylesheet" href="{skin:css/admin.css}" />
{js:jquery}
{js:dialog}
{js:form}
{js:validate}
{js:artTemplate}
<script type='text/javascript' src='{theme:javascript/artTemplate/area_select.js}'></script>
<script type='text/javascript' src="{theme:javascript/admin.js}"></script>
</head>
<body style="width:730px">

<div class="pop_win">
	<form action="{url:/order/order_return_doc}" method="post" id="return_form">
		<input type="hidden" name="order_no" value="{$order_no}"/>
		<input type="hidden" name="id" value="{$order_id}"/>
		<input type="hidden" name="weight_total" id="weight_total" value="{$goods_weight}"/>
		<input type="hidden" name="user_id" value="{$user_id}"/>
		<input type="hidden" name="ogid" id="ogid" value="{$ogid}"/>
		<input type="hidden" name="freight" value="{$real_freight}" />

		<table width="90%" class="border_table" style="margin:10px auto">
			<col width="100px" />
			<col />
			<col width="100px" />
			<col />
			<tbody>
				<tr>
					<th>订单号:</th><td align="left">{$order_no}</td>
					<th>下单时间:</th><td align="left">{$create_time}</td>
				</tr>
				<tr>
					<th>退货原因:</th>
					<td align="left" colspan="3">
					<select name="reason">
						<option value="质量原因">质量原因</option>
						<option value="无理由">无理由</option>
						<option value="其他">其他</option>
					</select>
					</td>
				</tr>
				<tr>
					<th>配送方式:</th>
					<td align="left" >
						<select name="delivery_type" pattern="required" alt="请选择配送方式">
						{query:name=delivery where=is_delete eq 0}
							<option value="{$item['id']}" {if:$distribution==$item['id']}selected{/if}>{$item['name']}</option>
						{/query}
						</select>
					</td>
					<th>配送费用:</th><td align="left">{$real_freight}</td>
				</tr>
				<tr>
					<th>配送单号:</th><td align="left" colspan="3"><input type="text" class="small" name="delivery_code" pattern="required"/></td>
				</tr>
				<tr>
					<th>是否保价:</th><td align="left">{if:$if_insured==0}否{else:}是{/if}</td>
					<th>保价费用:</th><td align="left">￥{$insured}</td>
				</tr>
				<tr>
					<th>退货人姓名:</th><td align="left"><input type="text" class="small" name="name" id="name" value="{$accept_name}" pattern="required"/></td>
					<th>电话:</th><td align="left"><input type="text" class="small" name="telphone" id="telphone" value="{$telphone}" pattern="phone" empty /></td>
				</tr>
				<tr>
					<th>手机:</th><td align="left"><input type="text" name="mobile" id="mobile" class="small" value="{$mobile}" pattern="mobi"/></td>
					<th>邮政编码:</th><td align="left"><input type="text" name="postcode" id="postcode" class="small" value="{$postcode}" pattern="zip"/></td>
				</tr>
				<tr>
					<th>退货地区:</th>
					<td align="left" colspan="3">
						<select name="province" child="city,area" onchange="areaChangeCallback(this);"></select>
						<select name="city" child="area" parent="province" onchange="areaChangeCallback(this);"></select>
						<select name="area" parent="city" pattern="required"></select>
					</td>
				</tr>
				<tr>
					<th>退货地址:</th><td align="left" colspan="3"><input type="text" class="normal" name="address" value="{$address}" pattern="required"/></td>
				</tr>
				<tr>
					<th>退货单备注:</th><td align="left" colspan="3"><textarea name="note" id="note" rows="3" cols="70"> </textarea></td>
				</tr>
			</tbody>
		</table>
		<table width="90%" class="border_table" style="margin:10px auto">
			<col />
			<col width="100px"/>
			<col width="100px" />
			<col width="100px" />
			<col width="100px" />
			<thead>
				<tr><th>商品名称</th><th>商品价格</th><th>购买数量</th><th>已退货</th><th>商品数量</th></tr>
			</thead>
			<tbody>
				{set:$ogid=''}
				{query: name=order_goods as og join=left join goods as gg on og.goods_id eq gg.id left join products as p on p.id eq og.product_id fields=gg.name as gname,p.spec_array as spec,og.id as ogid,og.product_id,og.goods_price,og.goods_array,og.goods_nums,og.real_price*og.goods_nums as total,og.real_price,og.shipments where=og.order_id eq $order_id}
					{set:$ogid .=$item['ogid'].',';}
					<tr>
						<td style="white-space:normal">
							{$item['gname']}
							{if:$item['spec']}
							&nbsp;&nbsp;
							{set:$specData = JSON::decode($item['spec']);}
							{foreach:items=$specData item=$value}
								{echo:$value['name']}:{if:$value['type']==1}{$value['value']}{else:}<img src="{echo:IUrl::creatUrl().$value['value']}" width="15px" height="15px" class="spec_photo" />{/if}&nbsp;&nbsp;
							{/foreach}
							{/if}
						</td>
						<td>{$item['real_price']}</td>
						<td>{$item['goods_nums']}</td>
						<td>{$item['shipments']}</td>
						<td>{$item['goods_nums']}</td>
					</tr>
				{/query}
			</tbody>
		</table>
	</form>
</div>

<script type="text/javascript">
//DOM加载完毕
$(function(){
	//初始化地域联动
	template.compile("areaTemplate",areaTemplate);

	createAreaSelect('province',0,{$province});
	createAreaSelect('city',{$province},{$city});
	createAreaSelect('area',{$city},{$area});
});

/**
 * 生成地域js联动下拉框
 * @param name
 * @param parent_id
 * @param select_id
 */
function createAreaSelect(name,parent_id,select_id)
{
	//生成地区
	$.getJSON("{url:/block/area_child}",{"aid":parent_id,"random":Math.random()},function(json)
	{
		$('[name="'+name+'"]').html(template.render('areaTemplate',{"select_id":select_id,"data":json}));
	});
}
</script>
</body>
</html>